#!/usr/bin/python


def func():
    global x# If you want set or change a global variable in function, you must adorned the variable with 'global'.

    print 'x is', x
    x = 2
    print 'Changed local x to', x
    print 'y is', y#'y' is a global variable too.But you can not change it's value here. 尽量不要这样用，这样会让人不知道这个变量到底定义在哪里. 

x = 50
y = 20
func()
print 'Value of x is', x
